package com.xinchao.service;

import com.xinchao.exception.ServiceException;
import com.xinchao.model.Department;
import com.xinchao.model.User;
import com.xinchao.model.dto.DepartmentTreeDTO;
import com.xinchao.model.page.PageInfo;
import com.xinchao.model.vo.DepartmentListVO;
import com.xinchao.model.vo.DepartmentSelectListVO;

import javax.servlet.http.HttpServletRequest;
import java.rmi.ServerException;
import java.util.HashMap;
import java.util.List;

/**
 * 部门Service
 *
 * @author dxy
 * @date 2018/6/21 16:39
 */
public interface DepartmentService {
	/**
	 * 保存部门
	 *
	 * @param department Department
	 * @param cityCodes  城市编码
	 * @param cityCodes  城市名称
	 * @param request    HttpServletRequest
	 */
	void insertDepartment(Department department, String cityCodes, String cityNames, HttpServletRequest request) throws ServerException;

	/**
	 * 修改部门
	 *
	 * @param department Department
	 * @param cityCodes    城市编码
	 * @param cityNames    城市名称
	 * @param request    HttpServletRequest
	 */
	void updateDepartment(Department department, String cityCodes, String cityNames, HttpServletRequest request) throws ServerException;

	/**
	 * 通过部门ID获取部门
	 *
	 * @param departmentId 部门ID
	 * @return Department
	 */
	Department getDepartmentById(Long departmentId);

	/**
	 * 部门列表
	 *
	 * @param status         状态
	 * @param departmentName 部门名称
	 * @param pageNum        当前页
	 * @param pageSize       每页条数
	 * @return Page<DepartmentListVO>
	 */
	PageInfo<DepartmentListVO> listDepartment(Integer status, String departmentName, Integer pageNum, Integer pageSize);

	/**
	 * 获取所有启用的部门
	 *
	 * @return List<DepartmentSelectListVO>
	 */
	List<DepartmentSelectListVO> listDepartmentSelect();

	/**
	 * 获取部门树列表
	 *
	 * @return List<DepartmentTreeDTO>
	 */
	List<DepartmentTreeDTO> listDepartmentTree();


	/**
	 * 保存部门省市区关系
	 *
	 * @param department 部门实体类
	 * @param areaIdArray  省市区ID字符串数组
	 * @param cityNames  城市名称
	 */
	void saveDepartmentArea(Department department, String[] areaIdArray, String cityNames, HttpServletRequest request) throws ServerException;

	/**
	 * 通过部门ID删除部门省市区关系
	 *
	 * @param departmentId 部门ID
	 */
	void deleteDepartmentAreaByDepartmentId(Long departmentId) throws ServerException;

	/**
	 * 通过部门ID查找部门所有用户
	 * hanqr 2018-08-09
	 * @param departmentId 部门ID
	 * @return
	 */
	List<HashMap<String,String>> getUsersByDepartmentId(Long departmentId);

	/**
	 * 启用禁用部门
	 * @param departmentId 部门ID
	 * @param status 状态
	 * @param request HttpServletRequest
	 * @throws ServerException
	 */
	void enableDisableDepartment(Long departmentId, Integer status, HttpServletRequest request) throws ServerException;

	/**
	 * 批量启用部门
	 * @param ids 部门id（多个英文逗号隔开）
	 * @param status 状态
	 * @param loginUser 登录用户
	 * @param ip 登录用户的ip
	 * @author linqiang
	 */
    void batchAbleDisable(String ids, Integer status, User loginUser, String ip) throws ServiceException;
}
